-- SPDX-License-Identifier: GPL-3.0-or-later

local extension = Package:new("sanshe_derived", Package.CardPack)
extension.extensionName = "sanshe"

extension:loadSkillSkelsByPath("./packages/sanshe/pkg/sanshe_derived/skills")

Fk:loadTranslationTable{
  ["sanshe_derived"] = "散设·衍生牌",
}

local enemy_at_the_gates = fk.CreateCard{
  name = "&sanshe__enemy_at_the_gates",
  type = Card.TypeTrick,
  skill = "sanshe__enemy_at_the_gates_skill",
}
extension:addCardSpec("sanshe__enemy_at_the_gates")
Fk:loadTranslationTable{
  ["sanshe__enemy_at_the_gates"] = "兵临城下",
  [":sanshe__enemy_at_the_gates"] = "锦囊牌<br /><b>时机</b>：出牌阶段<br /><b>目标</b>：一名其他角色<br /><b>效果</b>：你展示牌堆顶的四张牌，依次对目标角色使用其中的【杀】，然后将其余的牌以原顺序放回牌堆顶。",
}

extension:loadCardSkels {
  enemy_at_the_gates,
}

local foresight = fk.CreateCard{
  name = "&sanshe__foresight",
  type = Card.TypeTrick,
  skill = "sanshe__foresight_skill",
}
extension:addCardSpec("sanshe__foresight")
Fk:loadTranslationTable{
  ["sanshe__foresight"] = "洞烛先机",
  [":sanshe__foresight"] = "锦囊牌<br/>"..
  "<b>时机</b>：出牌阶段<br/>"..
  "<b>目标</b>：你<br/>"..
  "<b>效果</b>：目标角色卜算2（观看牌堆顶的两张牌，将其中任意张以任意顺序置于牌堆顶，其余以任意顺序置于牌堆底），然后摸两张牌。",

  ["sanshe__foresight_skill"] = "洞烛先机",
  ["#sanshe__foresight_skill"] = "观看牌堆顶两张牌，以任意顺序置于牌堆顶或牌堆底，然后摸两张牌",

  ["#PutCardTop"] = " %card 被置于牌堆顶",
  ["#PutCardBottom"] = " %card 被置于牌堆底",
}

extension:loadCardSkels {
  foresight,
}

local muma_skels = require("packages.sanshe.pkg.sanshe_derived.skills.muma.muma")
for i, skel in ipairs(muma_skels) do
  table.insert(extension.skill_skels, skel)
  local role__wooden_ox = fk.CreateCard{
    name = "&role__wooden_ox_"..i,
    type = Card.TypeEquip,
    sub_type = Card.SubtypeTreasure,
    equip_skill = "role__wooden_ox_skill_"..i.."&",
  
    on_uninstall = function(self, room, player)
      Treasure.onUninstall(self, room, player)
      player:setSkillUseHistory("role__wooden_ox_skill_"..i.."&", 0, Player.HistoryPhase)
    end,
  }
  extension:loadCardSkels{ role__wooden_ox }
  extension:addCardSpec("role__wooden_ox_"..i, Card.Diamond, 5)
  local muma_name_list = {"大","二","小"}
  local muma_name,muma_name_ = muma_name_list[i].."牛","【"..muma_name_list[i].."牛】"
  Fk:loadTranslationTable{
    ["role__wooden_ox_"..i] = muma_name,
    [":role__wooden_ox_"..i] = "装备牌·宝物<br/><b>宝物技能</b>：<br/>" ..
    "出牌阶段限一次，你可将一张手牌扣置于装备区里的"..muma_name_.."下（称为“辎”，“辎”至多有5张），然后你可以将"..muma_name_.."置入一名"..
    "其他角色的装备区。你可以如手牌般使用或打出“辎”。",
    ["wooden_ox"] = "木牛流马",
    ["role__wooden_ox_skill_"..i.."&"] = muma_name,
    [":role__wooden_ox_skill_"..i.."&"] = "出牌阶段限一次，你可将一张手牌扣置于装备区里的"..muma_name_.."下（称为“辎”，“辎”至多有5张），然后你可以将"..muma_name_.."置入一名"..
    "其他角色的装备区。你可以如手牌般使用或打出“辎”。",
    ["#role__wooden_ox_"..i.."-move"] = "你可以将"..muma_name_.."移动至一名其他角色的装备区",
    ["$role_carriage_"..i] = muma_name,
    ["#role__wooden_ox_"..i] = "你可以将一张手牌扣置于"..muma_name_.."下",
  }
  
end



return extension
